package Pile2;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Testo4 {
    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        while (true) {
            System.out.print("请输入文件名:");
            String name = s.next();
            File file = new File(name);
            if (file.exists()) {
                System.out.println("文件名已存在,请重新输入....");
            } else {
                file.createNewFile();
                System.out.println("文件已创建！");
                break;
            }


//        Scanner s=new Scanner(System.in);
//            System.out.print("请输入文件名:");
//            String name = s.next();
//            File file = new File(name);
//            File file1 = new File("./jsd2302");
//            if (file.getName() == file1.getName()) {
//                System.out.println("文件名已存在,请重新输入....");
//            }
//            else {
//                file.createNewFile();
//                System.out.println("文件已创建！");
//        }
        }
    }
}
